﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Kokomo.Xml
{
	public class RuntimePropertySchema : PropertySchema
	{
		public RuntimePropertySchema(PropertyInfo property, PropertyNodeType nodeType, string nodeName, PropertySchemaFlags flags)
			: base(nodeName, property.PropertyType, nodeType, flags)
		{
			ArgumentValidation.CheckNullArgument("property", property);

			this.Property = property;
		}

		public PropertyInfo Property { get; private set; }

		public override object GetValue(object target)
		{
			return this.Property.GetValue(target, null);
		}

		public override void SetValue(object target, object value)
		{
			this.Property.SetValue(target, value, null);
		}
	}
}
